<?php
// +----------------------------------------------------------------------
// | Description: about us
// +----------------------------------------------------------------------
// | Author: orchief
// +----------------------------------------------------------------------
// | Date: 2018-03-06 13:37:11
// +----------------------------------------------------------------------

namespace App\Model;

use App\Common\Model;
use App\Utility\Extend\Category;
use App\Utility\Extend\Tree;

class Rule extends Model
{
    protected $fuzzyConditions = null;
    protected $clearConditions = null;
    protected $returnFields = '';
    protected $rangeConditions = null;
    protected $union_fuzzyConditions = null;
    protected $foreignConditions = null;

    protected $name = 'admin_rule';
    /**
     * [getDataList 获取列表]
     * @param     Array                   $param [是否为树状结构]
     * @return    [array]
     */
    public function getDataList($param)
    {
        $cat = new Category('admin_rule', array('id', 'pid', 'title', 'title'));
        $data = $cat->getList('', 0, 'id');
        // 若type为tree，则返回树状结构
        if (isset($param['type']) && $param['type'] == 'tree') {
            foreach ($data as $k => $v) {
                $data[$k]['check'] = false;
            }
            $tree = new Tree();
            $data = $tree->list_to_tree($data, 'id', 'pid', 'child', 0, true, array('pid'));
        }

        return $data;
    }
}
